<template>
	<div class="article-edit">
		<el-card class="!border-none" shadow="never">
			<div class="flex justify-between">
				<el-page-header :content="$route.meta.title" @back="$router.back()" />
				<div>
					<el-button v-perms="['cooperation.cooperation/isDispute']" type="primary" @click="handleChange(formData.id, formData.is_dispute)">变更纠纷</el-button>
					<el-button v-perms="['cooperation.cooperation/closeCooperation']" type="danger" @click="handleClose(formData.id)">取消合作</el-button>
				</div>
			</div>
		</el-card>
		<el-tabs class="align-middle" v-model="defaultTab" @tab-change="handleTab">
			<el-tab-pane label="合作信息" name="合作信息">
				<el-card class="mt-4 !border-none" header="基础信息" shadow="never">
					<el-form ref="formRef" :inline="true" class="ls-form" :model="formData" label-width="120px">
						<el-form-item label="所属城市：">
							<span v-city="formData.area_id"></span>
						</el-form-item>
						<el-form-item label="合作类型：">
							<span v-if="formData.mode == 1">渠道合作</span>
							<span v-if="formData.mode == 2">固定介绍费</span>
							<span v-if="formData.mode == 3">双方分成</span>
							<span v-if="formData.mode == 5">双方分成</span>
						</el-form-item>
						<el-form-item label="合作编号：">{{formData.sn}}</el-form-item>
						<el-form-item label="创建时间：">{{formData.create_time}}</el-form-item>
						<el-form-item label="确认合作时间：">{{formData.confirm_time}}</el-form-item>
						<el-form-item label="合作状态：">{{formData.status==1?'待确认':formData.status==2?'进行中':formData.status==3?'已完成':formData.status==4?'已取消':''}}</el-form-item>
						<el-form-item label="纠纷：">{{formData.is_dispute == 1 ? '是':'否'}}</el-form-item>
						<div v-if="formData.mode == 1" style="width: 100%;">
							<el-form-item label="合作进度：" style="width: 100%;">
								<div class="steps-content">
									<el-steps :active="formData.product_bussiness_stage.length + 1" simple>
										<!-- <el-step title="确认合作" icon="none" /> -->
										<el-step v-for="item in formData.product_bussiness_stage" :title="item.name" icon="none" />
									</el-steps>
								</div>
								
							</el-form-item>
						</div>
					</el-form>
				</el-card>
				<el-card v-if="formData.mode == 1 && formData.product" class="mt-4 !border-none" header="业务信息" shadow="never">
					<el-form ref="formRefOne" :inline="true" class="ls-form" :model="formData" label-width="120px">
						<el-form-item label="所需额度：">{{(formData.quota/10000).toFixed(2)}}万</el-form-item>
						<el-form-item label="利率：">{{ (formData.rate * 100).toFixed(2) }}%</el-form-item>
						<el-form-item label="年限：">{{formData.credit_year}}年</el-form-item>
						<el-form-item label="渠道费：">{{Number(formData.service_fee).toFixed(2)}}元</el-form-item>
						<el-form-item label="用款时间：">{{formData.use_money_time}}</el-form-item> 
						<el-form-item label="业务类型：">{{formData.product_cate?formData.product_cate.name: formData.product.cate_name || ''}}</el-form-item> 
						<!-- <el-form-item label="纠纷">{{formData.is_dispute == 1 ? '是':'否'}}</el-form-item> -->
					</el-form>
					<table class="dataTable" border="0" cellspacing="0">
						<tbody>
							<tr>
								<th>产品id</th>
								<th>产品分类</th>
								<th>银行</th>
								<th>产品名称</th>
								<th>产品logo</th>
								<th>最高额度（万）</th>
								<th>授信期限</th>
								<th>利率类型</th>
								<th>利率值</th>
								<th>还款方式</th>
								<th>准入区域</th>
							</tr>
							<tr>
								<td>{{formData.product.sn}}</td>
								<td>{{formData.product.cate_name || ''}}</td>
								<td>{{formData.product.bank_name}}</td>
								<td>{{formData.product.name}}</td>
								<td>
									<image-contain v-if="formData.product.logo" :src="formData.product.logo" :width="60" :height="45" :preview-src-list="[formData.product.logo]" preview-teleported fit="contain" />
								</td>
								<td>{{formData.product.quota}}</td>
								<td>
									<template v-for="(child, index) in formData.product.credit_year" :key="'credit_year'+index"> {{ child }}年/ </template>
								</td>
								<td>{{ formData.product.rate_type == 1 ? '年化利率' : '日化利率' }}</td>
								<td>
									{{ formData.product.rate_type == 1 ? ((Math.round(formData.product.rate_start * 10000)/100).toString() + '%') : ((Math.round(formData.product.rate_start * 100000)/100).toString() + '‰') }}
									-
									{{ formData.product.rate_type == 1 ? (Math.round(formData.product.rate_end * 10000)/100).toString() + '%' : (Math.round(formData.product.rate_end * 100000)/100).toString() + '‰' }}
								</td>
								<td v-if="formData.product.repayment_type">{{ localGetRepaymentTypeText(formData.product.repayment_type) }}</td>
								<td v-if="formData.product.access_area_arr">{{ localGetAccessAreasText(formData.product.access_area_arr) }}</td>
							</tr>
						</tbody>
					</table>
				</el-card>
				<el-card v-if="formData.mode != 1" class="mt-4 !border-none" header="业务信息" shadow="never">
					<el-form ref="formRefTwo" :inline="true" class="ls-form" :model="formData" label-width="120px">
						<el-form-item label="客户姓名：">{{formData.customer_name}}</el-form-item>
						<el-form-item v-if="formData.mode != 2" label="客户电话：">{{formData.customer_phone}}</el-form-item>
						<el-form-item v-if="formData.mode != 2" label="业务类型：">{{formData.product_cate?formData.product_cate.name: formData.product.cate_name || ''}}</el-form-item>
						<el-form-item v-if="formData.mode != 2" label="所需额度：">{{(formData.quota/10000).toFixed(2)}}万</el-form-item>
						<el-form-item v-if="formData.mode != 2" label="用款时间：">{{formData.use_money_time}}</el-form-item> 
						<el-form-item label="介绍费：">
							<span v-if="formData.mode == 2">{{ Number(formData.service_fee).toFixed(2) }}元</span>
							<span v-if="formData.mode == 3">{{ (formData.rate * 100) }}%</span>
							
						</el-form-item> 
						<el-form-item v-if="formData.mode == 3" label="居间服务费：">{{Number(formData.private_fee).toFixed(2)}}元</el-form-item>
						<el-form-item v-if="formData.mode == 2" label="平台服务费：">{{Number(formData.city_platform_fee).toFixed(2)}}元</el-form-item> 
					</el-form>
				</el-card>
				<el-card class="mt-4 !border-none" header="用户信息" shadow="never">
					<table class="dataTable" border="0" cellspacing="0">
						<tbody>
							<tr>
								<th>用户名称</th>
								<th>头像</th>
								<th>组织机构名称</th>
								<th>手机号</th>
							</tr>
							<tr>
								<td>{{formData.user.real_name}}</td>
								<td>
									<image-contain v-if="formData.user.avatar" :src="formData.user.avatar" :width="60" :height="45" :preview-src-list="[formData.user.avatar]" preview-teleported fit="contain" />
								</td>
								<td>{{formData.user.userCompany?.business_name}}</td>
								<td>{{formData.user.account}}</td>
							</tr>
						</tbody>
					</table>
				</el-card>
				<el-card class="mt-4 !border-none" header="渠道信息" shadow="never">
					<table class="dataTable" border="0" cellspacing="0">
						<tbody>
							<tr>
								<th>所属场地</th>
								<th>姓名</th>
								<th>头像</th>
								<th>职务</th>
								<th>微信号</th>
								<th>手机号</th>
								<th>公司</th>
								<th>地址</th>
								<th>主营业务</th>
							</tr>
							<tr>
								<td>{{formData.channelExtra?.officePlace?.name}}</td>
								<td>{{formData.channelExtra.real_name}}</td>
								<td>
									<image-contain v-if="formData.channelExtra.avator" :src="formData.channelExtra.avator" :width="60" :height="45" :preview-src-list="[formData.channelExtra.avator]" preview-teleported fit="contain" />
								</td>
								<td>{{formData.channelExtra.position}}</td>
								<td>{{formData.channelExtra.wechat_no}}</td>
								<td>{{formData.channelExtra.account}}</td>
								<td>{{formData.channelExtra.company_name}}</td>
								<td>{{formData.channelExtra.company_address}}</td>
								<td v-if="formData.channelExtra.product_cate_arr">{{localGetProductCateText(formData.channelExtra.product_cate_arr)}}</td>
							</tr>
						</tbody>
					</table>
				</el-card>
			</el-tab-pane>
			<el-tab-pane label="财务信息" name="财务信息">
				<el-card class="mt-4 !border-none" header="收款信息" shadow="never">
					<el-table size="large" :data="formData.commission_order_list">
						<el-table-column label="序号(ID)" prop="id" min-width="90" />
						<el-table-column label="单号" min-width="200" prop="sn">
							<template #default="{ row }">
								<router-link
									v-perms="['setting.pay.payConfig/commissionOrderDetail']"
									:to="{ path: getRoutePath('setting.pay.payConfig/commissionOrderDetail'), query: { id: row.id } }"
								>
									<el-link v-perms="['setting.pay.payConfig/commissionOrderDetail']" type="primary" :underline="false">{{ row.sn }}</el-link>
								</router-link>
							</template>
						</el-table-column>
						<el-table-column label="款项类型" min-width="120" prop="type">
							<template #default="{ row }">
								<span v-if="row.type == 1">渠道费</span>
								<span v-if="row.type == 2">介绍费和平台服务费</span>
								<span v-if="row.type == 3">定金</span>
							</template>
						</el-table-column>
						<el-table-column label="总金额（元）" min-width="140" prop="actual_money" />
						<el-table-column label="创建时间" min-width="190" prop="create_time" />
						<el-table-column label="抵扣金额（元）" min-width="140" prop="deduction_price" />
						<el-table-column label="实付金额（元）" min-width="140" prop="after_folding_price" />
						<el-table-column label="支付状态" min-width="140" prop="pay_status">
							<template #default="{ row }">
								<span>{{ payTxt(row.pay_status) }}</span>
							</template>
						</el-table-column>
						<el-table-column label="支付方式" min-width="140" prop="pay_type">
							<template #default="{ row }">
								<span v-if="row.pay_type == 1">微信</span>
								<span v-else-if="row.pay_type == 2">支付宝</span>
								<span v-else-if="row.pay_type == 3">对公</span>
								<span v-else-if="row.pay_type == 4">余额</span>
								<span v-else>-</span>
							</template>
						</el-table-column>
						<el-table-column label="支付流水号" min-width="200" prop="transaction_id">
							<template #default="{ row }">
								<span v-if="row.transaction_id">{{ row.transaction_id }}</span>
								<span v-else>-</span>
							</template>
						</el-table-column>
						<el-table-column label="支付时间" min-width="200" prop="pay_time">
							<template #default="{ row }">
								<span v-if="row.pay_time">{{ row.pay_time }}</span>
								<span v-else>-</span>
							</template>
						</el-table-column>
					</el-table>
				</el-card>
				<el-card class="mt-4 !border-none" header="退款信息" shadow="never">
					<el-table size="large" :data="formData.commission_refund_list">
						<el-table-column label="序号(ID)" prop="id" min-width="90" />
						<el-table-column label="单号" min-width="200" prop="sn" >
							<template #default="{ row }">
								<router-link
									v-perms="['setting.pay.payConfig/commissionOrderDetail']"
									:to="{ path: getRoutePath('setting.pay.payConfig/commissionOrderDetail'), query: { id: row.id } }"
								>
									<el-link v-perms="['setting.pay.payConfig/commissionOrderDetail']" type="primary" :underline="false">{{ row.sn }}</el-link>
								</router-link>
							</template>
						</el-table-column>
						<el-table-column label="款项类型" min-width="120" prop="type">
							<template #default="{ row }">
								<span v-if="row.type == 1">渠道费</span>
								<span v-if="row.type == 2">介绍费和平台服务费</span>
								<span v-if="row.type == 3">定金</span>
							</template>
						</el-table-column>
						<el-table-column label="总金额（元）" min-width="140" prop="actual_money" />
						<el-table-column label="创建时间" min-width="190" prop="create_time" />
						<el-table-column label="退积分" min-width="140" prop="use_integral" />
						<el-table-column label="实退金额（元）" min-width="140" prop="refund_amount" />
						<el-table-column label="退款状态" min-width="140" prop="refund_status">
							<template #default="{ row }">
								<span>{{ refundTxt(row.refund_status) }}</span>
							</template>
						</el-table-column>
						<el-table-column label="退款方式" min-width="200" prop="refund_type">
							<template #default="{ row }">
								<span v-if="row.refund_type == 1">微信</span>
								<span v-else-if="row.refund_type == 2">支付宝</span>
								<span v-else-if="row.refund_type == 3">对公</span>
								<span v-else-if="row.refund_type == 4">余额</span>
								<span v-else>-</span>
							</template>
						</el-table-column>
					</el-table>
				</el-card>
			</el-tab-pane>
			<el-tab-pane label="操作记录" name="操作记录">
				<!-- v-if="formData.mode == 1" -->
				<el-timeline>
					<el-timeline-item v-for="(item,index) in formData.operation_records" :key="'listData'+index" :timestamp="item.create_time" placement="top">
						<!-- action_way 1.发起，2.确认，3.取消 -->
						<!-- 动作类型: 1.达成合作 2.取消合作（取消合作） 3.修改合作（修改合作） 4.下一步 5.完结合作（完成合作） 6.撤销 7.支付定金 8.申请介入 9.提醒付款 10.支付/付尾款 11.退款 -->
						<el-card v-if="item.action_way==1">
							<p>
								{{item.person.real_name}} 发起
								<span v-if="item.action_type != 7">{{ typeTxt(item.action_type) }}</span>
								<span v-if="item.action_type == 7">同意合作并要求支付定金</span>
							</p>

							<p v-if="item.content && 
								(item.content.oldcontent.product_title || item.content.oldcontent.service_fee || item.content.oldcontent.quota || item.content.oldcontent.rate)"
							>变更内容：</p>

							<p v-if="item.content && item.content.newcontent.product_title && (item.content.oldcontent.product_title != item.content.newcontent.product_title)">
								产品由“{{item.content.oldcontent.product_title}}”变为“{{item.content.newcontent.product_title}}”
							</p>

							<p v-if="item.content && item.content.newcontent.quota && (Number(item.content.oldcontent.quota) != Number(item.content.newcontent.quota))">
								放款金额由“{{(item.content.oldcontent.quota/10000).toFixed(2)}}万元”变为“{{(item.content.newcontent.quota/10000).toFixed(2)}}万元”
							</p>

							<p v-if="item.content && item.content.newcontent.rate && (Number(item.content.oldcontent.rate) != Number(item.content.newcontent.rate))">
								利率由“{{(item.content.oldcontent.rate*10000/100).toFixed(2)}}%”变为“{{(item.content.newcontent.rate*10000/100).toFixed(2)}}%”
							</p>

							<p v-if="item.content && item.content.newcontent.credit_year && (Number(item.content.oldcontent.duration_type) == Number(item.content.newcontent.duration_type)) && item.content.newcontent.duration_type == 1 && (Number(item.content.oldcontent.credit_year) != Number(item.content.newcontent.credit_year))">
								期限由“{{item.content.oldcontent.credit_year}}年”变为“{{item.content.newcontent.credit_year}}年”
							</p>

							<p v-if="item.content && item.content.newcontent.credit_year && (Number(item.content.oldcontent.duration_type) == Number(item.content.newcontent.duration_type)) && item.content.newcontent.duration_type == 2 && (Number(item.content.oldcontent.credit_year) != Number(item.content.newcontent.credit_year))">
								期限由“{{item.content.oldcontent.credit_year}}月”变为“{{item.content.newcontent.credit_year}}月”
							</p>

							<p v-if="item.content && item.content.newcontent.duration_type && (Number(item.content.oldcontent.duration_type) != Number(item.content.newcontent.duration_type))">
								<span v-if="item.content.newcontent.duration_type == 1">期限由“{{item.content.oldcontent.credit_year}}月”变为“{{item.content.newcontent.credit_year}}年”</span>
								<span v-if="item.content.newcontent.duration_type == 2">期限由“{{item.content.oldcontent.credit_year}}年”变为“{{item.content.newcontent.credit_year}}月”</span>
								
							</p>

							<p v-if="item.content && item.content.newcontent.service_fee && (Number(item.content.oldcontent.service_fee) != Number(item.content.newcontent.service_fee))">
								渠道费由“{{Number(item.content.oldcontent.service_fee).toFixed(2)}}元”变为“{{Number(item.content.newcontent.service_fee).toFixed(2)}}元”
							</p>

							<p v-if="item.content && item.content.newcontent.use_money_time && (String(item.content.oldcontent.use_money_time) != String(item.content.newcontent.use_money_time))">
								放款时间由“{{item.content.oldcontent.use_money_time}}”变为“{{item.content.newcontent.use_money_time}}”
							</p>

							<p v-if="item.content && item.content.newcontent.product_cate_title && (String(item.content.oldcontent.product_cate_title) != String(item.content.newcontent.product_cate_title))">
								业务类型由“{{item.content.oldcontent.product_cate_title}}”变为“{{item.content.newcontent.product_cate_title}}”
							</p>

							<p v-if="item.action_type == 7 && item.content && item.content.commission_order">定金：{{ item.content.commission_order.actual_money }}元，单据号：{{ item.content.commission_order.sn }}，支付方式：{{ payTypeTxt(item.content.commission_order.pay_type) }}</p>							
						</el-card>
						<el-card v-if="item.action_way==2">
							<p>{{item.person.real_name}} 确认{{ typeTxt(item.action_type) }}</p>
							<!-- 定金 -->
							<p v-if="item.action_type == 7 && item.content && item.content.commission_order">定金：{{ item.content.commission_order.actual_money }}元，单据号：{{ item.content.commission_order.sn }}，支付方式：{{ payTypeTxt(item.content.commission_order.pay_type) }}</p>
							<!-- 支付的金额 模式2展示支付介绍费和平台服务费 -->
							<p v-if="formData.mode != 2 && item.action_type == 10 && item.content && item.content.commission_order">支付：{{ item.content.commission_order.actual_money }}元，单据号：{{ item.content.commission_order.sn }}，支付方式：{{ payTypeTxt(item.content.commission_order.pay_type) }}</p>
							<p v-if="formData.mode == 2 && item.action_type == 10 && item.content && item.content.commission_order">支付介绍费{{ Number(item.content.commission_order.service_fee).toFixed(2) }}元，平台服务费{{ item.content.commission_order.city_platform_fee }}元，单据号：{{ item.content.commission_order.sn }}，支付方式：{{ payTypeTxt(item.content.commission_order.pay_type) }}</p>
							<!-- 退款 -->
							<p v-if="item.action_type == 11 && item.content && item.content.commission_refund">退款：退款单号：{{ item.content.commission_refund.sn }}，退现金{{ item.content.commission_refund.refund_amount + item.content.commission_refund.use_money }}元，退积分{{ item.content.commission_refund.refund_integral }}个</p>
						</el-card>
						<el-card v-if="item.action_way==3">
							<p>{{item.person.real_name}} 拒绝{{ typeTxt(item.action_type) }}</p>
						</el-card>
					</el-timeline-item>
				</el-timeline>
				<!-- <template v-if="formData.mode != 1">
					<el-timeline>
						<el-timeline-item v-for="(item,index) in listData" :key="'listData'+index" :timestamp="item.create_time" placement="top">
							<el-card v-if="item.action_way==1">
								<p>{{item.person.real_name}} 发起变更</p>
								<p>变更内容：</p>
								<p v-if="item.content.oldcontent.product_title != item.content.newcontent.product_title">产品由“{{item.content.oldcontent.product_title}}”变为“{{item.content.newcontent.product_title}}”</p>
								<p v-if="item.content.oldcontent.product_cate_title != item.content.newcontent.product_cate_title">业务类型由“{{item.content.oldcontent.product_cate_title}}”变为“{{item.content.newcontent.product_cate_title}}”</p>
								<p v-if="Number(item.content.oldcontent.quota )!= Number(item.content.newcontent.quota)">所需额度由“{{(item.content.oldcontent.quota/10000).toFixed(2)}}万”变为“{{(item.content.newcontent.quota/10000).toFixed(2)}}万”</p>
								<p v-if="Number(item.content.oldcontent.service_fee) != Number(item.content.newcontent.service_fee)">渠道费由“{{(Number(item.content.oldcontent.service_fee).toFixed(2))}}元”变为“{{(Number(item.content.newcontent.service_fee)).toFixed(2)}}元”</p>
								<p v-if="Number(item.content.oldcontent.rate) != Number(item.content.newcontent.rate)">介绍费由“{{(Number(item.content.oldcontent.rate)*100)}}%”变为“{{(Number(item.content.newcontent.rate)*100)}}%”</p>
								<p v-if="item.content.oldcontent.use_money_time != item.content.newcontent.use_money_time">用款时间由“{{item.content.oldcontent.use_money_time}}”变为“{{item.content.newcontent.use_money_time}}”</p>
								<p v-if="item.content.oldcontent.customer_name != item.content.newcontent.customer_name">客户姓名由“{{item.content.oldcontent.customer_name}}”变为“{{item.content.newcontent.customer_name}}”</p>
								<p v-if="item.content.oldcontent.customer_phone != item.content.newcontent.customer_phone">客户电话由“{{item.content.oldcontent.customer_phone}}”变为“{{item.content.newcontent.customer_phone}}”</p>
								<p v-if="formData.mode == 3 && Number(item.content.oldcontent.private_fee) != Number(item.content.newcontent.private_fee)">居间服务费由“{{(Number(item.content.oldcontent.private_fee)).toFixed(2)}}元”变为“{{(Number(item.content.newcontent.private_fee)).toFixed(2)}}元”</p>
							</el-card>
							<el-card v-if="item.action_way==2">
								<p>{{item.person.real_name}} 确认变更</p>
							</el-card>
							<el-card v-if="item.action_way==3">
								<p>{{item.person.real_name}} 取消变更</p>
							</el-card>
						</el-timeline-item>
					</el-timeline>
				</template> -->
			</el-tab-pane>
		</el-tabs>

		<el-dialog
			v-model="dialogVisible"
			title="变更纠纷"
			width="360"
		>
			<div class="dispute-flex">
				<span>纠纷</span>
				<el-radio-group v-model="radio">
					<el-radio :label="1">是</el-radio>
					<el-radio :label="0">否</el-radio>
				</el-radio-group>
			</div>
			
			<div class="dispute-flex">
				<el-button @click="()=>{dialogVisible = false}">取消</el-button>
				<el-button type="primary" @click="onRight">确认</el-button>
			</div>
		</el-dialog>
	</div>
</template>

<script lang="ts" setup name="cooperateDetail">
	import type { FormInstance } from 'element-plus';
	import { cooperationDetail, cooperationOperationRecords, cooperationClose, isDispute } from '@/api/cooperate/lists';
	import { getRoutePath } from "@/router";
	import { toRaw, shallowRef } from "vue";
	import {isEmpty} from "@/utils/util";
	import feedback from '@/utils/feedback';
	const route = useRoute();
	const router = useRouter();
	// 支付状态文字转化
	//动作类型: 1.达成合作 2.取消合作（取消合作） 3.修改合作（修改合作） 4.下一步 5.完结合作（完成合作） 6.撤销 7.支付定金 8.申请介入 9.提醒付款 10.支付/付尾款 11.退款
	const typeTxt = (num:any) => {
		return computed(():string=>{
			let txt = '';
			switch(num) {
				case 1: txt = '达成合作';break;
				case 2: txt = '取消合作';break;
				case 3: txt = '修改合作';break;
				case 4: txt = '下一步 ';break;
				case 5: txt = '完成合作 ';break;
                case 6: txt = '撤销 ';break;
				case 7: txt = '同意合作并支付定金';break;
				case 8: txt = '申请介入 ';break;
				case 9: txt = '提醒付款 ';break;
				case 10: txt = '支付渠道费';break;
				case 11: txt = '退款 ';break;
			}
			return txt;
		})
	}
	const payTxt = (num:any) => {
		return computed(():string=>{
			let txt = '';
			switch(num) {
				case 1: txt = '待支付';break;
				case 2: txt = '支付中';break;
				case 3: txt = '等待确认（对公）';break;
				case 4: txt = '支付成功 ';break;
				case 5: txt = '支付失败 ';break;
				case 6: txt = '已作废 ';break;
			}
			return txt;
		})
	}
	const refundTxt = (num:any) => {
		return computed(():string=>{
			let txt = '';
			switch(num) {
				case 1: txt = '待退款';break;
				case 2: txt = '退款中';break;
				case 3: txt = '等待确认（对公）';break;
				case 4: txt = '已退款 ';break;
				case 5: txt = '退款失败 ';break;
			}
			return txt;
		})
	}
	const payTypeTxt = (num:any) => {
		return computed(():string=>{
			let txt = '';
			switch(num) {
				case 1: txt = '微信';break;
				case 2: txt = '支付宝';break;
				case 3: txt = '对公';break;
				case 4: txt = '钱包支付 ';break;
			}
			return txt;
		})
	}
	const formData:any = reactive({
		area_id: '',
		mode: '',
		id: '',
		sn: '',
		create_time: '',
		status: null,
		quota: 0,
		rate: 0,
		city_platform_fee: 0,
		credit_year: 0,
		service_fee: 0,
		use_money_time: '',
		product: {
			sn: '',
			cate_name: ''
		},
		user: {},
		channelExtra: {},
		is_dispute: 0,
		private_fee: '',
		product_bussiness_stage: [],
		product_cate: {
			name: ''
		},
		customer_name: '',
		customer_phone: '',
		confirm_time: '',
		operation_records: [{
			content:{
				newcontent: {
					product_title: '',
					service_fee: '',
					quota: '',
					rate: ''
				},
				oldcontent: {
					product_title: '',
					service_fee: '',
					quota: '',
					rate: ''
				}
			}
		}],
		commission_order_list: [],
		commission_refund_list: []
	})
	const dialogVisible = ref(false)
	const radio = ref(0)
	const dispute_id = ref()
	const handleChange = (id:any, is_dispute:number) => {
		console.log(id, is_dispute)
		dispute_id.value = id;
		radio.value = is_dispute;
		dialogVisible.value = true;
	}
	const onRight = async () => {
		console.log(dispute_id.value)
		console.log(radio.value)
		await isDispute({
			id: dispute_id.value,
			is_dispute: radio.value
		})
		dialogVisible.value = false;
		route.query.id && getDetails()
	}
	const handleClose = async (id : number) => {
		await feedback.confirm('取消合作之后，合作状态将变为“已取消”，确认取消该合作？')
		await cooperationClose({ id })
		route.query.id && getDetails()
	}
	// const listData = reactive({
	// 	id: '',
	// 	person: {},
	// 	cooperation_id: null,
	// 	action_type: null,
	// 	action_way: null,
	// 	action_way_time: null,
	// 	action_user_or_channel_id: null,
	// 	person_type: null,
	// 	content: {},
	// 	create_time: '',
	// 	update_time: ''
	// })
	let listData:any = ref([])
	const formRef = shallowRef<FormInstance>()
	const formRefOne = shallowRef<FormInstance>()
	const formRefTwo = shallowRef<FormInstance>()
	const defaultTab = ref('合作信息')
	const getDetails = async () => {
		const data = await cooperationDetail({
			id: route.query.id
		})
		Object.keys(formData).forEach((key) => {
			//@ts-ignore
			
			if (key == 'product') {
				if (data[key] == null) {
					formData.product.cate_name = ''
				}
			} else {
				formData[key] = data[key]
			}
		})
		console.log(formData)
		
		const list = await cooperationOperationRecords({id:route.query.id})
		listData.value = list;
	}
	const localGetRepaymentTypeText = (repaymentTypes: number[]| null): string => {
	  //1.先息后本 2.等额本息 3.等额本金
	  let repaymentTypeStr = ''
	  if (!isEmpty(repaymentTypes)) {
	    (repaymentTypes as number[]).forEach((item,index )  => {
	      if (item == 1) {
	        repaymentTypeStr += '先息后本/'
	      } else if (item == 2) {
	        repaymentTypeStr += '等额本息/'
	      } else if (item == 3) {
	        repaymentTypeStr += '等额本金/'
	      } else if (item == 4) {
	        repaymentTypeStr += '一次性还本付息/'
	      } else if (item == 5) {
	        repaymentTypeStr += '随借随还/'
	      }
	    })
	  }
	  return repaymentTypeStr.slice(0, -1)
	}
	const localGetAccessAreasText = (accessAreaArr: Array<any>): string => {
	  let accessAreaText = ''
	  accessAreaArr.forEach((item, index) => {
	    accessAreaText += (item?.Name)+'/'
	  })
	  return accessAreaText.replace(/[\\//]$/, "");
	}
	const localGetProductCateText = (productCateArr: Array<any>): string => {
	  let productCateText = ''
	  productCateArr.forEach((item, index) => {
	    productCateText += (item?.name)+'/'
	  })
	  return productCateText.replace(/[\\//]$/, "");
	}
	const handleTab = (val:any)=>{
		console.log(val,123);
	}
	route.query.id && getDetails()
</script>
<style scoped lang="scss">
.ls-form{
	::v-deep .el-form-item{
		width: 30%;
	}
}
.steps-content{
	// width: 600px;
	::v-deep .el-steps--simple{
		padding: 5px 0;
	}
	::v-deep .el-step.is-simple{
		flex-basis: 25% !important;
	}
	::v-deep .el-step__main{
		white-space: nowrap;
	}
	::v-deep .el-step.is-simple .el-step__title{
		font-size: 12px;
		min-width: 60px;
	}
}
.dispute-flex{
	display: flex;
	justify-content: center;
	align-items: center;
	margin-bottom: 20px;
	span{
		margin-right: 20px;
	}
}
	// .dataTable {
	// 	width: 100%;
	// 	line-height: 40px;
	// 	text-align: left;
	// 	border-top: 1px solid #eaeaea;
	// 	border-left: 1px solid #eaeaea;
	// 	border-right: 1px solid #eaeaea;

	// 	tr {
	// 		// display: flex;

	// 		th {
	// 			flex: 1;
	// 			min-height: 40px;
	// 			padding: 0 16px;
	// 			font-weight: 500;
	// 			font-size: 12px;
	// 			color: #fff;
	// 			// background: #f9f8f8;
	// 			border-bottom: 1px solid #eaeaea;
	// 			border-right: 1px solid #eaeaea;
	// 		}

	// 		td {
	// 			flex: 1;
	// 			min-height: 40px;
	// 			padding: 0 16px;
	// 			font-size: 12px;
	// 			color: #fff;
	// 			border-bottom: 1px solid #eaeaea;
	// 			border-right: 1px solid #eaeaea;
	// 		}
	// 	}
	// }
</style>